package com.bluesky.javawebbrowser.domain.html.tags.form.select;

import com.bluesky.javawebbrowser.domain.html.tags.Tag;
import com.bluesky.javawebbrowser.domain.html.tags.TagType;

public class Option extends Tag {
	private String value;
	private boolean selected;

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
		attributes.put("value", value);
	}

	public boolean getSelected() {
		return selected;
	}

	public void setSelected(boolean selected) {
		this.selected = selected;
		if(selected)
			attributes.put("selected", null);
		else
			attributes.remove("selected");
	}

	public Option() {
		super(TagType.OPTION);
	}

	public Option(Tag tag) {
		super(TagType.OPTION);

		copy(tag);
	}
	
	public void setLabel(String label){
		Tag labelTag = new Tag(TagType.TEXT_BLOCK);
		labelTag.setBody(label);
		
		removeAllChildren();
		addChild(labelTag);
	}
	
	public static void main(String[] args) {
		Option op = new Option();
		op.setValue("1");
		op.setLabel("a1");
		
		System.out.println(op.toHtml());
	}
}
